<template>
	<view class="pay">
		<!-- 金额 -->
		<view class="pay_text flex-column-center">
			<view class="font-7d766b font14">支付金额 (元)</view>
			<text class="font-ef9140 font25">{{dataObj.money}}</text>
		</view>
		<!-- 边框 -->
		<view class="com_border"></view>
		<!-- 详情 -->
		<view class="pay_info">
			<view class="pay_box flex-row-between font13">
				<text>体检人</text>
				<view>{{dataObj.physical_user_name}}</view>
			</view>
			<view class="pay_box flex-row-between font13">
				<text>体检人手机</text>
				<view>{{dataObj.physical_user_mobile}}</view>
			</view>
			<view class="pay_box flex-row-between font13">
				<text>体检时间</text>
				<view>{{dataObj.time}} {{dataObj.begin_time}}~{{dataObj.end_time}}</view>
			</view>
			<view class="pay_box flex-row-between font13">
				<text>体检地址</text>
				<view>{{conobj.physical_h_addr}}</view>
			</view>
			<view class="pay_box flex-row-between font13">
				<text>咨询电话</text>
				<view>{{conobj.physical_h_tel}}</view>
			</view>
			<view class="pay_box flex-row-between font13">
				<text>下单时间</text>
				<view>{{dataObj.createtime}}</view>
			</view>
			<!-- <view class="pay_box flex-row-between font13" v-if="dataObj.pay_status==1">
				<text>支付时间</text>
				<view>2021-10-21 19:30:20</view>
			</view> -->
		</view>
		<!-- 边框 -->
		<view class="com_border"></view>
		<!-- 套餐详情 -->
		<view class="pay_package">
			<view v-for="(item,index) in packageList" :key="index" class="package_list">
				<view class="package_title font14 font-878787 flex-row-start">
					{{item.name}}({{item.physical_project_number}})项
				</view>
				<view class="package_bos">
					<view class="package_box font14 font-646464" v-for="(item1,index1) in item.physical_project"
						:key="index" :class="index1==item.physical_project.length-1?'package_box_0':''">
						<view class="package_box_title">{{item1.name}}</view>
						<view class="package_box_info">{{item1.synopsis}}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 立即预约 -->
		<view class="pay_menu flex-row-between">
			<view></view>
			<view class="menu_submit flex-row-center font-ffffff font13" @click="OnPay">立即支付</view>
		</view>
		<view class="pay_menus"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				conobj:{},
				dataObj: {}, //详情
				getobj: {}, //项目详情
				code: null, //订单code
				// 套餐详情
				packageList: []
			}
		},
		onLoad: function(options) {
			this.code = options.code
			//获取详情
			this.Oninfo()
			//公共接口
			this.Onconfig()
		},
		methods: {
			Onconfig() {
				this.$Http({
					url: 'consultationConsult',
					data: {}
				}).then(res => {
					if (res.code == 1) {
						this.conobj = res.data
					}
				})
			},
			//获取详情
			Oninfo() {
				this.$Http({
					url: 'detailsPhysicalOrder',
					data: {
						order_code: this.code
					}
				}).then(res => {
					if (res.code == 1) {
						res.data.createtime = this.$base.formatTime(new Date(res.data.createtime *
							1000), "yyyy/MM/dd hh:mm:ss")
						if (res.data.pay_status == 1) {
							// res.data.createtime = this.$base.formatTime(new Date(res.data.createtime *
							// 	1000), "yyyy/MM/dd hh:mm:ss")
						}
						this.dataObj = res.data
						//获取项目详情
						this.Getinfo()
					}
				})
			},
			//获取项目详情
			Getinfo() {
				this.$Http({
					url: 'physicalDetails',
					data: {
						physical_id: this.dataObj.physical_id
					}
				}).then(res => {
					if (res.code == 1) {
						this.getobj = res.data
						this.packageList = res.data.physical_project
					}
				})
			},
			//支付
			OnPay() {
				let that = this
				this.$Http({
					url: 'payPhysicalOrder',
					data: {
						order_code: this.code,
					},
					type: 'POST',
				}).then(res => {
					uni.requestPayment({
						provider: 'wxpay',
						timeStamp: res.data.timeStamp,
						nonceStr: res.data.nonceStr,
						package: res.data.pacKage,
						signType: res.data.signType,
						paySign: res.data.paySign,
						success: function(res1) {
							uni.redirectTo({
								url: '/pagesA/check/detail/detail?code='+that.code,
							})
						},
						fail: function(err) {
							uni.showModal({
								title: '支付提示',
								confirmText: '确定',
								confirmColor: '#ff4646',
								showCancel: false,
								content: '支付失败',
								success: function(res) {
									if (res.confirm) {
										uni.redirectTo({
											url: '/pagesA/check/list/list',
										})
									}
								},
							});

						}
					});
				})
			},
			//订单详情
			Ondetail() {
				uni.navigateTo({
					url: '/pagesA/check/detail/detail',
				})
			}
		}
	}
</script>

<style lang="less">
	@import url("pay.less");
</style>
